package com.tom.architect.day16;

import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;
import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Retrofit;

import com.tom.architect.R;
import com.tom.architect.day16.simple3.DarrenRetrofit;
import com.tom.architect.day16.simple3.RetrofitClient;
import com.tom.architect.day16.simple3.ServiceInterface;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.xml.transform.Result;

/**
 * 代理设计模式
 */
public class MainActivity16 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main16);

        DarrenRetrofit retrofit = new DarrenRetrofit();
        // 核心代码，会返回一个ServiceInterface的实例对象。主要的思想在create里面
        ServiceInterface serviceInterface = retrofit.create(ServiceInterface.class);

        String result =  serviceInterface.userLogin();
        Log.d("TAG", "result:" + result);
//        Call<String> call = serviceInterface.userLogin();
//        call.enqueue(null);


//        OkHttpClient okHttpClient = new OkHttpClient.Builder()
////                .readTimeout().addInterceptor().connectTimeout()
//                .build();
//        Retrofit retrofit = new Retrofit.Builder()
//                .client(okHttpClient).build();
//        testMethod();
    }

    private void testMethod() {
        Map<String, Object> params = new HashMap<>();
        params.put("pageNo", 1);
//        Call<Result> call = RetrofitClient.getService().testMethod(params);
//        //  加入队列去执行
//        call.enqueue(new Callback<Result>() {
//            @Override
//            public void onFailure(Call call, IOException e) {
//            }
//
//            @Override
//            public void onResponse(Call call, Response response) throws IOException {
//            }
//        });
    }


}